
package br.ufpb.lavid.pamin.daos;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;


public class ConexaoDao {

	private Connection connection;
    private Statement statement;
    
    public void conectar(){
    	
    	ConfiguracaoDao c = new ConfiguracaoDao();
    	
    	try{
    		Class.forName(c.getDriverName());
    		connection = DriverManager.getConnection(c.getUrl(), c.getUsername(), c.getPassword());


            if (connection != null)
            	System.out.println("STATUS--->Conectado com sucesso!");
            else 
               System.out.println("STATUS--->Não foi possivel realizar conexão");
            
            statement = connection.createStatement();  //para consultar o banco
    	
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    	
    }//conectar
	
    public Connection getConnection() {
		return connection;
	}

	public Statement getStatement() {
		return statement;
	}

	public void desconectar(){
    	
    	try{
    		connection.close();
    		statement.close();
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    
    }//desconectar
    
}//classe
